#!/usr/local/bin/python3.5
# -*- coding utf-8
import flask
import functools
from flask import request

app = flask.Flask(__name__)


def require(**required_args):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kv):
            for args in required_args:
                if args not in request.json:
                    return flask.abort(400)
            return func(*args, **kv)
        return wrapper
    return decorator


@app.errorhandler(400)
def not_found(error="参数不正确!"):
    return flask.make_response(flask.jsonify({'error': error}), 400)
